<?php 
//Funciones para operar con archivos y otros
require("../funciones.php"); 
require("../funcionesDB.php"); 
open_html();


if(isset($_REQUEST['noticia_id'])) {
echo "22".$_REQUEST['noticia_id'];
	$newsString = "select noticia_id,title,body,insert_dt,status from noticias where noticia_id=".$_REQUEST['noticia_id'];
	$newsQuery = dbSelect($newsString) or die("Error en select ".$newsString." ".mysql_error());;
	$newsResult = mysql_fetch_array($newsQuery);
} else if(isset($_REQUEST['preview'])) {
	$newsResult['noticia_id'] = 0;
	$newsResult['title'] = $_REQUEST['title'];
	$newsResult['body'] = $_REQUEST['FCKeditor1'];
	$newsResult['insert_dt'] = now();
	$newsResult['status'] = 'A';
}
?>

<head>
<?php do_header("Calibula - ".$newsResult['title']); ?>
<link rel="stylesheet" type="text/css" href="/calibula/css/noticia/styles.css" />
</head>

<body bgcolor="#F0F0F0">
<center>

<div id="wrap"> 
   	<div id="header"></div>

	<div id="container">
		<div id="content-wrap">
			<div id="nav1">
				<ul id="menus">
					<li class="current"><a href="/calibula">Home</a></li>
					<li><a href="#">Noticias</a></li>
					<li><a href="#">RSS</a></li>
					<li><a href="#">Contacto</a></li>
				</ul>
			</div>
			<div id="title">
				<h1><?php echo $newsResult['title']; ?></h1>
			</div>
			<div id="subtitle">
				<?php 
					setlocale( LC_TIME, "spanish" );
					echo strftime( "%A %d %B %Y", strtotime($newsResult['insert_dt']));
					if(isset($_REQUEST['noticia_id'])) {
						$tagsString = "select t.name from tags_noticias tn, tags t where tn.tag_id=t.tag_id and tn.noticia_id=".$_REQUEST['noticia_id'];
						$tagsQuery = dbSelect($tagsString) or die("Error en select ".$tagsString." ".mysql_error());;
						$isFirst = true;
						while ($tagsResult = mysql_fetch_array($tagsQuery)) {
							if($isFirst) {
								echo " - Tags: ";
								$isFirst = false;
							} else {
								echo " - ";
							}
							echo "<a href='../tags/".$tagsResult['name']."'>".$tagsResult['name']."</a>";
						}
					}

				?>
			</div>
			<div id="main">
				<?php echo $newsResult['body']; ?>
			</div>					
			<div id="sidebar">
				<h3>AdSense</h3>
				<ul class="sidemenu">
					<li><a href="#">Category 1</a></li>
					<li><a href="#">Category 2</a></li>
					<li><a href="#">Category 3</a></li>					
					<li><a href="#">Category 4</a></li>
					<li><a href="#">Category 5</a></li>
				</ul>
	
				<p>&nbsp;</p>
				<h3>RSS</h3>
				<p>
				Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed non risus. 
				Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor. 
				Cras elementum ultrices diam. Maecenas ligula massa, varius a, semper congue, euismod non, mi. 
				</p>
	
			</div>
			<div style="clear:both"></div>
  		</div>
   	</div>
</div>
<div id="footer-wrap">
	<div id="footer">&nbsp;</div>
	<div id="footer-content">
		<p>Calibula S.A.<p>
	</div>
</div>

</center>
</body>
<?php
close_html();
?>